VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ClsTipoServicio"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Public WithEvents orset As ClsRecordset
Attribute orset.VB_VarHelpID = -1

Public Event DataChanged()

Public codigo As String
Public nombre As String
Public descripcion As String

Private Sub Class_Initialize()
    Set orset = New ClsRecordset
    orset.setCampos dbCampos(tse)
    orset.setTablas Array(tse)
End Sub
Private Sub Class_Terminate()
    Set orset = Nothing
End Sub
Public Sub consulta()
    If GUsuario.tipo_id <> "1" Then
        orset.consultaGral , Array(tse, per), _
                           Array(per_tse_id & "=" & tse_id, _
                                 per_tus_id & "=" & GUsuario.tipo_id), _
                           Array(tse_nombre)
    Else
        orset.consulta , Array(tse_nombre)
    End If
End Sub
Public Sub consultaDatos(codig As String)
    orset.consulta Array(tse_id & "=" & codig)
    orset.CierraRec
End Sub
Public Sub consultaConTipoDocumento()
    If GUsuario.tipo_id <> "1" Then
        orset.consultaGral , Array(tse, tdo, per), _
                           Array(tdo_tse_id & "=" & tse_id, _
                                 per_tse_id & "=" & tse_id, _
                                 per_tus_id & "=" & GUsuario.tipo_id), _
                           Array(tse_nombre)
    Else
        orset.consultaGral , Array(tse, tdo), _
                           Array(tdo_tse_id & "=" & tse_id), _
                           Array(tse_nombre)
    End If
End Sub
Public Sub consultaConGrupoVentaAuto()
    If GUsuario.tipo_id <> "1" Then
        orset.consultaGral , Array(tse, grv, per), _
                           Array(grv_tse_id & "=" & tse_id, _
                                 per_tse_id & "=" & tse_id, _
                                 per_tus_id & "=" & GUsuario.tipo_id), _
                           Array(tse_nombre)
    Else
        orset.consultaGral , Array(tse, grv), _
                           Array(grv_tse_id & "=" & tse_id), _
                           Array(tse_nombre)
    End If
End Sub
Public Sub consultaConDetalles()
    If GUsuario.tipo_id <> "1" Then
        orset.consultaGral Array("DISTINCT " & tse_id, tse_nombre, tse_descripcion), _
                           Array(tse, ser, dta, per), _
                           Array(ser_tse_id & "=" & tse_id, _
                                 dta_ser_id & "=" & ser_id, _
                                 per_tse_id & "=" & tse_id, _
                                 per_tus_id & "=" & GUsuario.tipo_id), _
                           Array(tse_nombre)
    Else
        orset.consultaGral Array("DISTINCT " & tse_id, tse_nombre, tse_descripcion), _
                           Array(tse, ser, dta), _
                           Array(ser_tse_id & "=" & tse_id, _
                                 dta_ser_id & "=" & ser_id), _
                           Array(tse_id)
    End If
End Sub

Public Sub Nuevo(newnom As String, newdesc As String)
    orset.sInsert Array("", newnom, newdesc)
End Sub
Public Sub Modificar(codig As String, newnom As String, newdesc As String)
    orset.sUpdate Array(codig, newnom, newdesc)
End Sub
Public Sub Borrar(codig As String)
    orset.sDelete Array(tse_id & "=" & Trim(codig))
End Sub
Private Sub Reload_members()
    With orset
        codigo = .getDato(tse_id, "")
        nombre = .getDato(tse_nombre)
        descripcion = .getDato(tse_descripcion)
    End With
    RaiseEvent DataChanged
End Sub
Public Sub llenaCombo(cajaCombo As ComboBox, conCodigo As Boolean, conOpcionTodos As Boolean)
    Dim i As Integer
    consulta
    i = 0
    cajaCombo.Clear
    If conOpcionTodos Then
        cajaCombo.AddItem "(Todos)"
        'cajaCombo.ItemData(i) = "0"
        i = i + 1
    End If
    If conCodigo Then
        While orset.CanMoveNext
            cajaCombo.AddItem codigo & " - " & nombre
            cajaCombo.ItemData(i) = codigo
            orset.MoveNext
            i = i + 1
        Wend
    Else
        While orset.CanMoveNext
            cajaCombo.AddItem nombre
            cajaCombo.ItemData(i) = codigo
            orset.MoveNext
            i = i + 1
        Wend
    End If
    If conOpcionTodos And cajaCombo.ListCount > 0 Then
        If cajaCombo.ListIndex < 0 Then
            cajaCombo.ListIndex = 0
        End If
    End If
End Sub
Public Sub llenaComboConGrupoVentaAuto(cajaCombo As ComboBox, conCodigo As Boolean, conOpcionTodos As Boolean)
    Dim i As Integer
    consultaConGrupoVentaAuto
    i = 0
    cajaCombo.Clear
    If conOpcionTodos Then
        cajaCombo.AddItem "(Todos)"
        'cajaCombo.ItemData(i) = "0"
        i = i + 1
    End If
    If conCodigo Then
        While orset.CanMoveNext
            cajaCombo.AddItem codigo & " - " & nombre
            cajaCombo.ItemData(i) = codigo
            orset.MoveNext
            i = i + 1
        Wend
    Else
        While orset.CanMoveNext
            cajaCombo.AddItem nombre
            cajaCombo.ItemData(i) = codigo
            orset.MoveNext
            i = i + 1
        Wend
    End If
    If conOpcionTodos And cajaCombo.ListCount > 0 Then
        If cajaCombo.ListIndex < 0 Then
            cajaCombo.ListIndex = 0
        End If
    End If
End Sub
Public Sub llenaComboSQL(cajaCombo As ComboBox, conCodigo As Boolean, conOpcionTodos As Boolean, sq As String)
    Dim i As Integer
    Dim q As ClsQuery
    Set q = New ClsQuery
    q.consulta sq
    i = 0
    cajaCombo.Clear
    If conOpcionTodos Then
        cajaCombo.AddItem "(Todos)"
        'cajaCombo.ItemData(i) = "0"
        i = i + 1
    End If
    If conCodigo Then
        While q.orset.CanMoveNext
            cajaCombo.AddItem q.valores_fila(0) & " - " & q.valores_fila(1)
            cajaCombo.ItemData(i) = q.valores_fila(0)
            q.orset.MoveNext
            i = i + 1
        Wend
    Else
        While q.orset.CanMoveNext
            cajaCombo.AddItem q.valores_fila(1)
            cajaCombo.ItemData(i) = q.valores_fila(0)
            q.orset.MoveNext
            i = i + 1
        Wend
    End If
    If conOpcionTodos And cajaCombo.ListCount > 0 Then
        If cajaCombo.ListIndex < 0 Then
            cajaCombo.ListIndex = 0
        End If
    End If
End Sub

Private Sub orset_DataChanged()
    Reload_members
End Sub
